import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.wizehack.mri.SFLocalizer;
import org.wizehack.mri.fl.SFLAlgorithm;
import org.wizehack.mri.fl.Tarantula;
import org.wizehack.mri.test.BasicTestSuite;
import org.wizehack.mri.test.TestSuite;
import org.wizehack.mri.testSet.TestCaseReduction;
import org.wizehack.mri.testSet.VectorBasedStrategy;


public class VectorandSFLDemo extends SFLocalizer{

	private static String PROJECT_NAME = "GraphEditor2";
	private static String SOURCE_CODE_LOCATION = "/home/hsyoun/workspace/jgraphx/src/";

	private int NUMBER_OF_TEST_SUITE = 1;
	
	private static String ROOT_DIR = "/home/hsyoun/workspace/jgraphx/Data/5";

	@Override
	public void setUp() {
		super.createProject(PROJECT_NAME, SOURCE_CODE_LOCATION, NUMBER_OF_TEST_SUITE);
	}

	@Override
	public void registerTestSets() {	
		TestSuite[] testSuiteArray = new TestSuite[NUMBER_OF_TEST_SUITE];
		int[] numberOfTestCase = new int[NUMBER_OF_TEST_SUITE];
		
		TestCaseReduction strategy = new VectorBasedStrategy();
		List<String> failedCoverageFileList = new ArrayList<String>();

		failedCoverageFileList.add(ROOT_DIR + "/7.xml");
		failedCoverageFileList.add(ROOT_DIR + "/12.xml");
		failedCoverageFileList.add(ROOT_DIR + "/13.xml");
		failedCoverageFileList.add(ROOT_DIR + "/21.xml");

		for(int i=0; i<NUMBER_OF_TEST_SUITE; i++){
			String dirPath =  ROOT_DIR + File.separator;

			testSuiteArray[i] = new BasicTestSuite();
			strategy.setTestSuite(testSuiteArray[i]);
			strategy.setFailedCoverageFileList(failedCoverageFileList);
			strategy.setDirectory(dirPath);
			testSuiteArray[i] = strategy.select();
			super.addTestSuite(testSuiteArray[i]);
			numberOfTestCase[i] = testSuiteArray[i].size();
		}
		
		this.setNumberOfTestCase(numberOfTestCase);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		VectorandSFLDemo demo = new VectorandSFLDemo();
		demo.probe();
		SFLAlgorithm sfl = new Tarantula(); 
		demo.debug(sfl);
	}

}
